package com.itheima.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MpConfig {
    //TODO 配置拦截器
    @Bean
    public MybatisPlusInterceptor mpi(){
        //1.定义Mp拦截器
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        //2.添加具体的拦截器（分页）
        mpi.addInnerInterceptor(new PaginationInnerInterceptor());
        //2.添加具体的拦截器（乐观锁）
        mpi.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return mpi;
    }
}
